//package com.plian.system.controller.sys.warning;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.plian.Tools.CollectionUtil;
//import com.plian.system.config.Resubmit;
//import com.plian.system.dto.sys.warning.WarningFactorDTO;
//import com.plian.system.entity.sys.warning.WarningFactor;
//import com.plian.system.model.CommonCode;
//import com.plian.system.model.ListResult;
//import com.plian.system.model.R;
//import com.plian.system.model.token.PassToken;
//import com.plian.system.mybatis.search.SearchEntity;
//import com.plian.system.mybatis.search.SearchParamEntiy;
//import com.plian.system.mybatis.support.Condition;
//import com.plian.system.mybatis.support.Query;
//import com.plian.system.service.sys.warning.IWarningFactorService;
//import com.plian.system.service.sys.warning.IWarningFactorValueService;
//import com.plian.system.vo.fr.bulletin.BulletinTypeVO;
//import com.plian.system.vo.sys.warning.AutoExcelInfoVO;
//import com.plian.system.vo.sys.warning.SheetInfoVO;
//import com.plian.system.vo.sys.warning.WarningFactorVO;
//import com.plian.system.wrapper.sys.warning.WarningFactorWrapper;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.AllArgsConstructor;
//import org.springframework.web.bind.annotation.*;
//
//import javax.validation.Valid;
//import java.util.List;
//
//@RestController
//@AllArgsConstructor
//@RequestMapping(value = "api/warning/factor")
//@Api(value = "预警因子配置", tags = "预警因子配置接口")
//public class WarningFactorController {
//
//    private IWarningFactorService warningFactorService;
//    private WarningFactorWrapper warningFactorWrapper;
//
//    private IWarningFactorValueService warningFactorValueService;
//
//    @PostMapping(value = "detail")
//    @ApiOperation("详情")
//    public R<WarningFactorVO> detail(@RequestBody WarningFactor warningFactor){
//        return R.data(warningFactorService.detail(warningFactor));
//    }
//
//    @PostMapping(value = "list")
//    @ApiOperation("列表")
//    public ListResult<WarningFactorVO> list(@RequestBody Query query){
//        List<SearchEntity> entityList = query.getSearch();
//        if (query.getAscs()==null&&query.getDescs()==null){
//            query.setDescs("create_time");
//        }
//        QueryWrapper<WarningFactor> queryWrapper = SearchParamEntiy.getQueryWrapper(
//                Condition.getQueryWrapper(new WarningFactor()), entityList
//        );
//        IPage<WarningFactor> pages = warningFactorService.page(Condition.getPage(query), queryWrapper);
//        List<WarningFactorVO> systemVOS = warningFactorWrapper.entityToVO(pages.getRecords());
//        return new ListResult<>(systemVOS, CommonCode.SUCCESS, Long.valueOf(pages.getTotal()).intValue());
//    }
//
//    /**
//     * 新增或修改
//     */
//    @PostMapping("/submit")
//    @Resubmit(delaySeconds = 0)
//    @ApiOperation("新增或修改")
//    public R submit(@Valid @RequestBody WarningFactorVO warningFactorVO) {
//        return R.status(warningFactorService.submit(warningFactorVO));
//    }
//
//    /**
//     * 删除
//     */
//    @PostMapping("/remove")
//    @ApiOperation("删除")
//    public R remove(@RequestBody WarningFactorDTO warningFactorDTO) {
//        return R.status(warningFactorService.removeAndChild(warningFactorDTO));
//    }
//
//    @PostMapping("/sheet-list")
//    @ApiOperation("sheet列表")
//    public R<List<SheetInfoVO>> sheetList(@RequestBody WarningFactorDTO warningFactorDTO) {
//        return R.data(warningFactorService.sheetList(warningFactorDTO));
//    }
//
//    @GetMapping("/auto-excel-list")
//    @ApiOperation("获取自定义表格列表")
//    public R<List<AutoExcelInfoVO>> autoExcelList() {
//        return R.data(warningFactorService.autoExcelList());
//    }
//
//    @GetMapping("/bulletin-code-list/{year}")
//    @ApiOperation("根据年份获取快报字典")
//    public R<List<BulletinTypeVO>> bulletinCodeList(@PathVariable("year") String year) {
//        return R.data(warningFactorService.bulletinCodeList(year));
//    }
//
//    @GetMapping("/init/{year}")
//    @ApiOperation("根据年份初始化")
//    @PassToken
//    public void initAllByYear(@PathVariable("year") int year) {
//        warningFactorValueService.updateValueByYear(year);
//    }
//
//    @PostMapping("/update-value-by-ids")
//    @ApiOperation("根据ids、yearList更新数据")
//    public void initAllByYear(@RequestBody WarningFactorDTO warningFactorDTO) {
//        if (CollectionUtil.isNotEmpty(warningFactorDTO.getYearList())){
//            for (Integer year : warningFactorDTO.getYearList()) {
//                warningFactorValueService.updateValueByFactorIds(warningFactorDTO.getIds(), year);
//            }
//        }
//    }
//}
